﻿Imports System.Xml

Public Class DataXML
    Private pattTransID As String
    Private pattAgent As String
    Private pattDate As String
    Private pattTime As String
    Private pattDuration As String
    Private pattDnis As String
    Private pattANI As String
    Private pattStatus As String
    Private pattConnid As String
    Private pattCallDirection As String
    Private pattNameFile As String
    Private xmlDoc2 As New XmlDocument


    Public WriteOnly Property TransID() As String
        Set(ByVal value As String)
            pattTransID = value
        End Set
    End Property


    Public WriteOnly Property Agent() As String
        Set(ByVal value As String)
            pattAgent = value
        End Set
    End Property

    Public WriteOnly Property pDate() As String
        Set(ByVal value As String)
            pattDate = value
        End Set
    End Property

    Public WriteOnly Property pTime() As String
        Set(ByVal value As String)
            pattTime = value
        End Set
    End Property


    Public WriteOnly Property Duration() As String
        Set(ByVal value As String)
            pattDuration = value
        End Set
    End Property

    Public WriteOnly Property ANI() As String
        Set(ByVal value As String)
            pattANI = value
        End Set
    End Property

    Public WriteOnly Property DNIS() As String
        Set(ByVal value As String)
            pattDnis = value
        End Set
    End Property

    Public WriteOnly Property Status() As String
        Set(ByVal value As String)
            pattStatus = value
        End Set
    End Property

    Public WriteOnly Property Connid() As String
        Set(ByVal value As String)
            pattConnid = value
        End Set
    End Property

    Public WriteOnly Property CallDirection() As String
        Set(ByVal value As String)
            pattCallDirection = value
        End Set
    End Property

    Public WriteOnly Property NameFile() As String
        Set(ByVal value As String)
            pattNameFile = value
        End Set
    End Property

    Public Function WriteXML(ByVal archXml2 As String) As Boolean
        Try
            xmlDoc2.Load(archXml2)

            Dim elemNew As XmlElement = xmlDoc2.CreateElement("transaction")
            Dim attTransID As XmlAttribute = xmlDoc2.CreateAttribute("trans_id")
            Dim attAgent As XmlAttribute = xmlDoc2.CreateAttribute("agent")
            Dim attDate As XmlAttribute = xmlDoc2.CreateAttribute("date")
            Dim attTime As XmlAttribute = xmlDoc2.CreateAttribute("time")
            Dim attDuration As XmlAttribute = xmlDoc2.CreateAttribute("duration")
            Dim attDnis As XmlAttribute = xmlDoc2.CreateAttribute("dnis")
            Dim attANI As XmlAttribute = xmlDoc2.CreateAttribute("ANI")
            Dim attStatus As XmlAttribute = xmlDoc2.CreateAttribute("status")
            Dim attConnid As XmlAttribute = xmlDoc2.CreateAttribute("connid")
            Dim attCallDirection As XmlAttribute = xmlDoc2.CreateAttribute("call_direction")
            Dim attNameFile As XmlAttribute = xmlDoc2.CreateAttribute("namefile")

            attTransID.Value = pattTransID
            attAgent.Value = pattAgent
            attDate.Value = pattDate
            attTime.Value = pattTime
            attDuration.Value = pattDuration
            attDnis.Value = pattDnis
            attANI.Value = pattANI
            attStatus.Value = pattStatus
            attConnid.Value = pattConnid
            attCallDirection.Value = pattCallDirection
            attNameFile.Value = pattNameFile

            xmlDoc2.DocumentElement.AppendChild(elemNew)
            elemNew.Attributes.Append(attTransID)
            elemNew.Attributes.Append(attAgent)
            elemNew.Attributes.Append(attDate)
            elemNew.Attributes.Append(attTime)
            elemNew.Attributes.Append(attDuration)
            elemNew.Attributes.Append(attDnis)
            elemNew.Attributes.Append(attANI)
            elemNew.Attributes.Append(attStatus)
            elemNew.Attributes.Append(attConnid)
            elemNew.Attributes.Append(attCallDirection)
            elemNew.Attributes.Append(attNameFile)
            xmlDoc2.Save(archXml2)

            elemNew = Nothing
            attTransID = Nothing
            attAgent = Nothing
            attDate = Nothing
            attTime = Nothing
            attDuration = Nothing
            attDnis = Nothing
            attANI = Nothing
            attStatus = Nothing
            attConnid = Nothing
            attCallDirection = Nothing
            attNameFile = Nothing

            WriteXML = True

        Catch ex As Exception
            DS3.log(ex.Message)
            WriteXML = False
        End Try

    End Function


End Class


